package com.elmcode.server.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elmcode.common.utils.PageUtils;
import com.elmcode.common.utils.Query;

import com.elmcode.server.dao.BookDetailDao;
import com.elmcode.server.entity.BookDetailEntity;
import com.elmcode.server.service.BookDetailService;


@Service("bookDetailService")
public class BookDetailServiceImpl extends ServiceImpl<BookDetailDao, BookDetailEntity> implements BookDetailService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BookDetailEntity> page = this.page(
                new Query<BookDetailEntity>().getPage(params),
                new QueryWrapper<BookDetailEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<BookDetailEntity> selectByBookNum(String num) {
        List<BookDetailEntity> bookDetailEntities = this.baseMapper.selectList(new QueryWrapper<BookDetailEntity>().eq("book_id", num));
        return bookDetailEntities;
    }

    @Override
    public void delectByBookId(String num) {

        this.baseMapper.delete(new QueryWrapper<BookDetailEntity>().eq("book_id",num));
    }

}